package com.example.indenture.common;



import com.example.indenture.user.entity.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 获取当前session
 *
 * @author CY
 * @date 2023/03/15 09:09
 **/
public class SessionUtil {
    public static User getSession(HttpServletRequest request) {
        final HttpSession session = request.getSession(false);
        final User userInfo = (User) session.getAttribute(Constant.SESSION_USERINFO_KEY);
        if (userInfo != null && userInfo.getId() > 0) {
            return userInfo;
        }
        return null;
    }
}
